怎么把数组score[3][4]的首地址付给指针t ?

来源:百度知道 编辑:UC知道 时间:2024/05/27 15:28:58
代码:
// 903.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "iostream"
using namespace std;

float *find(float *pionter,int n);

int _tmain(int argc, _TCHAR* argv[])
{
static float score[3][4]={{60,70,80,90},{56,89,34,45},{34,23,100,34}};
float *p(float *pionter,int n);
float *t=score; //错误提示:无法从
int i,m; //“float (*__w64 )[3][4]”
//转换为“float *”

cout<<"Enter the number to be found:";
cin>>m;
cout<<"The score of "<<m<<"are"<<endl;
p=&find(*t,m);
for( i=0;i<4;i++)
cout<<*(p+i)<<" ";

return 0;
}

float *find(float *pionter,int n)
{
float *pt;
pt=*(pionter+n);
return(pt);
}
我按前四位答复者的参考都试过,却出现类似错误。5日16点22分

把float *t=score;拆成定义和赋值两行,即:

float *t;

t = &score[0][0];

score[3]+4*length[length为相应的数据的物理长度]

float *t=score[0][0];

score是数组的数组
你的t是一个指向float的指针
他俩类型不一样
试试float **t
如果你定义score[100][200]
以后访问score[i][j]的时候,就得这样:*(t+i*200+j)了,小心哦